	import Vue from 'vue'
	import Vuex from 'vuex'
	
	Vue.use(Vuex)
	
	export default new Vuex.Store({
		state: {
			topListIds: [],
			nextId:'',
		},
		mutations:{
			INIT_TOPLISTIDS(state, payload) {
				state.topListIds = payload
			},
			NEXT_ID(state, payload) {
				const length = state.topListIds.length
				for(let i=0; i<length; i++){
					if(i === length - 1) {
						state.nextId = state.topListIds[0].id
						break
					}
					if( state.topListIds[i].id == payload) {
						state.nextId = state.topListIds[i+1].id
					}
				}
			}
		},
		
	})
	